﻿using Application.Expand;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;

namespace AbpToDomain.EntityInfo
{
    public class TaskOrder :  AggregateRoot<Guid>
    {

        [Key]
        public Guid Id_TaskOrder { get; set; }
        public DateTime CreatTime { get; set; }
        [Comment("任务类型")]
        public string Type {  get; set; }
        public string? OrderNo { get; set; }
        [Comment("任务状态-未下发/已下发")]
        public string State { get; set; }
        [Comment("仓库坐标")]
        public string WarehouseCode { get; set; }
        [Comment("缓存坐标")]
        public string InlethouseCode { get; set; }
        [Comment("任务号")]
        public string TaskOrderCode { get; set; }
        [Comment("组优先级")]
        public int? groupPriority { get; set; }
        [Comment("任务优先级")]
        public int? taskPriority { get; set; }
        //foreignkey
        public Box Box { get; set; }
        public Guid Id_Box { get; set; }
        public PutOutOrder? PutOutOrder { get; set; }

        public List<NeetOutMaterial>? neetOutMaterials { get; set; }=new List<NeetOutMaterial>();

        //public WarehouseLine WarehouseLine { get; set; }
        //public Guid Id_WarehouseLine { get; set; }
        //public InlethouseLine InlethouseLine { get; set; }
        //public Guid Id_InlethouseLine { get; set; }
        //function
        public TaskOrder AddTaskOrder(string Type, Box box, string WarehouseCode,
            string InlethouseCode, string?OrderNo,int? groupPriority, int? taskPriority,string State)
        {
           TaskOrder taskOrder = new TaskOrder();
           taskOrder.Type = Type;
           taskOrder.Box = box;
           taskOrder.WarehouseCode = WarehouseCode;
           taskOrder.InlethouseCode = InlethouseCode;
           taskOrder.OrderNo = OrderNo;
           taskOrder.State = State;
           taskOrder.CreatTime = DateTime.Now;
           taskOrder.groupPriority = groupPriority;
           taskOrder.groupPriority=groupPriority;
           taskOrder.TaskOrderCode = ExtendRandom.CreateRandom();
           return taskOrder;
        }

        public override object[] GetKeys()
        {
            return new object[] { Id_TaskOrder };
        }
    }
}
